package edu.ec.java02.group02.util;

import edu.ec.java02.group02.domain.ProductInfo;

import java.util.*;

public class ListSort {
    public static void removeDuplicateWithOrder(List list) {
        Set set = new HashSet();
        List newList = new ArrayList();
        for (Iterator iter = list.iterator(); iter.hasNext();) {
            Object element = iter.next();
            if (set.add(element))
                newList.add(element);
        }
        list.clear();
        list.addAll(newList);
        System.out.println(" remove duplicate " + list);
    }

    public  static  void  removelist(List <ProductInfo>list){
        List newList = new ArrayList();
        for(int i =0;i<list.size();i++){
            for(int j = 0;j<i;j++){
                if(list.get(i).getProductId().equals(list.get(j).getProductId())){
                    newList.add(list.get(j));
                }

            }
        }
        list.removeAll(newList);
    }

}
